package cn.yunhe.spring.struts.interceptor;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;


/**
 * Created by Administrator on 2016/12/1.
 */
public class LoggInterceptor extends AbstractInterceptor {
    @Override
    public String intercept(ActionInvocation actionInvocation) throws Exception {
        System.out.println("对控制层的拦截器现在开始拦截。。。。。。。。");
        //开始拦截的时间
        Long starttime=System.currentTimeMillis();
        //继续下一个拦截器
        String result=actionInvocation.invoke();
        //拦截结束时间
        Long endtime=System.currentTimeMillis();
        System.out.println("对控制层的拦截器拦截现在结束拦截==========");
        //输出拦截器的信息
        System.out.println("这是"+actionInvocation.getProxy().getAction()+"类的"+actionInvocation.getProxy().getActionName()
                +"方法名"+actionInvocation.getProxy().getMethod()+"执行耗时："+(endtime-starttime));
        return result;
    }
}
